package com.web.all.common.bean.enums;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;

/**
 * 排序方式
 * @author lc
 */
@ApiModel(value = "OrderEnum", description = "排序方式")
public enum OrderEnum {
    /**
     * 正序
     */
    @ApiModelProperty(value = "正序")
    ASC("ASC"),
    /**
     * 倒序
     */
    @ApiModelProperty(value = "倒序")
    DESC("DESC");

    public final String value;

    OrderEnum(String value){
        this.value = value;
    }

    private static Map<String,OrderEnum> orderLoop = new HashMap<>();
    static {
        Stream.of(OrderEnum.values()).forEach(orderEnum -> orderLoop.put(orderEnum.value,orderEnum));
    }

    public static OrderEnum forCode(String value){
        return orderLoop.get(value);
    }
}
